import {reqCategoryList,reqBannerList,reqFloorList} from '@/api'
const state = {
    categoryList:[],
    bannerList:[],
    floorList:[]
};
const mutations = {
    REQ_CATEGROY(state,categoryList){
        state.categoryList = categoryList;
        
    },
    REQ_BANNERLIST(state,bannerList){
      state.bannerList = bannerList;
    },
    REQ_FLOORLIST(state,floorList){
      state.floorList = floorList;
    }
};

const actions = {
  //发请求拿数据提交给mutation
  async getCategoryList({commit}){
    const result = await reqCategoryList()
    if(result.code === 200){
      commit('REQ_CATEGROY',result.data)
    }
  },
  //发送mock请求到本地拿去数据
  async getBannerList({commit}){
    const result = await reqBannerList();
    if(result.code === 200){
      commit('REQ_BANNERLIST',result.data)
    }
  },
  async getFloorList({commit}){
    const result = await reqFloorList();
    if(result.code === 200){
      commit('REQ_FLOORLIST',result.data)
    }
  }
}
const getters = {};

export default {
    state,
    actions,
    mutations,
    getters,
}